<template lang="html">
  <div id="app" >
    <transition name="fade">
      <div  v-if="!hidden">
        <personalCon
        :host="host"
        :hb_key="hb_key"
        :total_money="total_money"
        :telVal="telVal"
        :total_rank_num="total_rank_num"
        :total_rank_money="total_rank_money"
        :is_register="is_register"
        :headimgurl="headimgurl"
        :invite_total_money="invite_total_money"
        :invite_people_count="invite_people_count"
        :res_list="res_list"
        :list="list"
        :u_event_total_money="u_event_total_money"
        :timestamp = 'timestamp'
        :nonceStr = 'nonceStr'
        :signature = 'signature'
        :appId = 'appId'
        :shareurl = 'shareurl'
        ></personalCon>
        <!--真二维码-->
        <img class="erweima-y" src="../../assets/erweima.png" style="">
        <jrFooter></jrFooter>
      </div>
    </transition>

    <loader
    :loading="loading" :color="color" :size="size"
    v-if="hidden" :class="classObject" ></loader>
  </div>
</template>

<script>
  // vue相对路径不能省略，必须是以./ ../开头 ，绝对路径以/开头
  import RingLoader from 'vue-spinner/src/RingLoader.vue'
  import personalCon from '../../components/Personal.vue'
  import jrFooter from '../../components/JrFooter.vue'
  // 引入详情页
  export default {
    name: 'personal',
    data () {
      return {
        number : 10,
        topshow: false,
        hidden: true,
        isRegister: false,
        color: '#000',
        size: '5rem',
        loading: true,
        loadTop: 500,
        url: '/HunanLaohuji/hblist',
        urlEntrance: 'http://hbjr.jinrgame.com/HunanLaohuji/hb_list',
        isOneScreen: true,
        countImg: 0,
        host: '',
        hb_key: '',
        telVal: '',
        dataShuj: '',
        is_register: false,
        total_rank_num: '0',
        total_rank_money: '0',
        huansdianji: '点击下载送5000元',
        total_money: '0',
        headimgurl: '',
        invite_total_money: "",
        invite_people_count: "",
        res_list: [],
        list: [],
        u_event_total_money: '',
        timestamp : 0,
        nonceStr : '',
        signature : '',
        appId : '',
        shareurl: ''
      }
    },
    computed: {
      //{oneScreen: isOneScreen, heiScree}
      classObject: function () {
        return {
          active: this.isActive && !this.error,
          'oneScreen': this.isOneScreen,
        }
      }
    },
    created () {

      let val = this.getRequest()
      this.host = val['host']
      this.hb_key = val['hb_key']

      let url = this.initGetUrl(this.host)
      this.$http.get(url,  {
        params: {
          hb_key: this.hb_key
        }
      }).then((response) => {  // Lambda写法
        response = response.data;
        if(response.code=10000){
          this.hidden = false
          this.total_money = response.data.total_money
          this.telVal = response.data.tel
          this.res_list = response.data.res_list
          this.list = response.data.list
          this.total_rank_num = response.data.total_rank.total_num
          this.total_rank_money = response.data.total_rank.total_money
          this.invite_total_money = response.data.invite_total_money
//          this.u_event_total_money = response.data.u_event_total_money
          this.invite_people_count = response.data.invite_people_count
          this.headimgurl = response.data.userinfo.headimgurl

          this.appId = response.data.data.appId
          this.timestamp = response.data.data.timestamp
          this.nonceStr = response.data.data.nonceStr
          this.signature = response.data.data.signature
          this.shareurl = response.data.data.shareurl

          this.is_register = response.data.is_register==0 ? false : true
        }
      });

      this.$root.eventHub.$on('showRegisterFun', (val) => {
        this.$nextTick(() => {
          console.log("负组件")
          this.hidden = true
          this.isRegister = true

        });
      });

//      let response = {
//        "code": 10000,
//        "data": {
//          "total_money": "9834",
//          "invite_total_money": 0,
//          "invite_people_count": "0",
//          "tel": "14800000000",
//          "list": [{
//            "id": "15571033",
//            "u_id": "1276631",
//            "is_my": "0",
//            "u_openid": "oKwexww0hhOvVtzoIFBk4HgCTNfY",
//            "invite_u_id": "0",
//            "invite_u_openid": "oKwexwyZfLLDYMqB27qBCDFuJ45E",
//            "invite_u_tel": "18566663647",
//            "event_key": "GAME_TYPE_XIAN_HUNAN_LAO_HU_JI",
//            "hb_status": null,
//            "platform": null,
//            "hb_money": "500",
//            "hb_desc": null,
//            "hb_source": null,
//            "s_time": null,
//            "e_time": null,
//            "c_time": "2017-04-26 14:51:11",
//            "u_time": null,
//            "read": "0",
//            "ip_address": null,
//            "hb_type": null,
//            "user_type": null,
//            "action": null,
//            "tickey": "0",
//            "nickname": "ZIHUA",
//            "headimgurl": "http://wx.qlogo.cn/mmopen/qvMONxRJBBeOPqFOCkJY51b2FdyrqhzmbITa5iaJx1siaf8IoIWIna1UqoeELx66rngosPzt17WOycJthtOjpxkEmmbULj4dKr/0",
//            "invite_total_money": "8784"
//          }],
//          "res_list":  [
//              {
//                "open_id": "oKwexww0hhOvVtzoIFBk4HgCTNfY",
//                "u_invite_count": "0",
//                "u_event_total_money": "9834",
//                "c_time": "2017-04-24 14:33:48",
//                "nickname": "哥舒带把刀",
//                "mingci": 1,
//                "headimgurl": "http://wx.qlogo.cn/mmopen/Q3auHgzwzM5iaC3SyHm0beTuxR3E1cCLIKJB5CQpBBhHCfte3X8sgRYkd37ANicywqw34mBQzr5bTic8hibboqwaIQ/0"
//              },
//              {
//                "open_id": "oKwexwyZfLLDYMqB27qBCDFuJ45E",
//                "u_invite_count": "0",
//                "u_event_total_money": "8784",
//                "c_time": "2017-04-24 20:10:56",
//                "nickname": "ZIHUA",
//                "mingci": 2,
//                "headimgurl": "http://wx.qlogo.cn/mmopen/qvMONxRJBBeOPqFOCkJY51b2FdyrqhzmbITa5iaJx1siaf8IoIWIna1UqoeELx66rngosPzt17WOycJthtOjpxkEmmbULj4dKr/0"
//              }
//            ],
//
//          "total_rank": {
//            "total_num": "2",
//            "total_money": "18618"
//          },
//          "data": {
//            "code": null,
//            "openid": "oKwexww0hhOvVtzoIFBk4HgCTNfY",
//            "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3cab169b09ae473c&redirect_uri=http%3A%2F%2Fhbjr.jinrgame.com%2FHunanLaohuji%2Fgame_get_openid%3Fhb_key%3DHFa%2BXIiDttdqNggNZPcNmxL%2Bfa4RUDARIbMZeOv3jonR2lNEio4Id%2FOj6NlU4o4PR78yzV6mJtW3wDDMbHdmdqbKLuDjin7lCTkMN5i2IKruADRW1nFGw3jdhA1POp0tEqb51NIGPmCaRqs85zKQgDZsK%2BZ3b906zULtbY6kWbrn6fTfRDDNdhYTazd4zRj0nnwEQMNdxToDaB2n2y3Ckg%3D%3D&response_type=code&scope=snsapi_base&state=121#wechat_redirect",
//            "appId": "wx3cab169b09ae473c",
//            "timestamp": 1493173916,
//            "nonceStr": "8uaHV71AMH7j6KGS",
//            "signature": "0a7abbcec4e3a702268fd0b4acafe97ee3915531",
//            "hb_key": "VU8HqGLmAia0FLYYzl6I7HgTmkkBf3TTg0TI606E3V/xmWF3PiKa/NJgrT1CjTIEVE5jYwDPV/nqf17A072tqO4ANFbWcUbDeN2EDU86nS0SpvnU0gY+YJpGqzznMpCA7CnYiG80OCCGO5QfINKaI9BE0LPOx+dGRBOp7qqF8c7CUOwJf5vej6AOmWHuiJ396x1AZJOaZ67zvzOMkeDZ8Pt5dBi+akdBXFSfHdhnoQxQ+7w2mt3g1hEMJlNkRbI2",
//            "jsapi_ticket": "kgt8ON7yVITDhtdwci0qeXWDOCfMGwmKhi3Zx5QlcquuEjB4KWE7u_ocWZRL-CtWpScLFi4oDmjCdvJh8gpjmw",
//            "oauth2": null,
//            "shareurl": "http://hbjr.jinrgame.com/jump/hbnewtaylor/hbcommon?hb_key=X2R32Fet36ONR9IHHA5OoOTnbZATnCn2lwRSazCRYwwdS0R9ZV9K91msnegSqVmJTCFnGH2+mcQqduMS/DjEPFnlxcj/gASBI6T/8nlsD+yr12JSRI/HbeLunvbCQae9bFP4yFY+BOZCx96/QBUVxKITofYrga92moX1v/yS0pK44qiNXZd5x/wAxaEQl7BwXeQekZqB19/H9d3/7PwPa/v8w97wTNDXvqSHZBmTT7ivlmq256x//VmywN5t5lazUBRhnrd7GPOmpgIHRZh4AAVtEZ2Tv0NdDrygJ/IkKWcP7RK3Sccs9nXa0nfl7dXQyciZq4l6gFZV93drsE8rwZAW/f/OZPUAGy8GCKRo6pGZjNojNVXJM17RUR9qYhrzHJq45oRx79dKhK0eToWJKg=="
//          },
//          "url": "http://jrdev.jingyubank.com/m/",
//          "is_register": 1,
//          "hb_key": "VU8HqGLmAia0FLYYzl6I7HgTmkkBf3TTg0TI606E3V++2J+czaUlgyBV1ZbTbWPWlt9DN7QjnUg4N+vK06N6LB7A75QImWL2pImN+bjSRddPmQQBk/HzEKlgu/AMDbKcJQ6GoOB45mv3UfQAt0ZBm+sdQGSTmmeu878zjJHg2fD7eXQYvmpHQVxUnx3YZ6EMUPu8Nprd4NYRDCZTZEWyNg==",
//          "userinfo": {
//            "id": "1376830",
//            "uid": null,
//            "openid": "oKwexww0hhOvVtzoIFBk4HgCTNfY",
//            "event_key": "GAME_TYPE_XIAN_HUNAN_LAO_HU_JI",
//            "nickname": "哥舒带把刀",
//            "sex": "1",
//            "province": "福建",
//            "city": "厦门",
//            "country": "中国",
//            "headimgurl": "http://wx.qlogo.cn/mmopen/Q3auHgzwzM5iaC3SyHm0beTuxR3E1cCLIKJB5CQpBBhHCfte3X8sgRYkd37ANicywqw34mBQzr5bTic8hibboqwaIQ/0",
//            "unionid": null,
//            "c_time": "2017-04-21 12:01:31",
//            "u_time": "2017-04-21 12:01:31",
//            "give_state": "0",
//            "show_state": "0"
//          }
//        }
//      }
//      if(response.code=10000){
//        this.hidden = false
//        this.total_money = response.data.total_money
//        this.telVal = response.data.tel
//        this.res_list = response.data.res_list
//        this.list = response.data.list
//        this.list = response.data.list
//        this.total_rank_num = response.data.total_rank.total_num
//        this.total_rank_money = response.data.total_rank.total_money
//        this.invite_total_money = response.data.invite_total_money
//        this.invite_people_count = response.data.invite_people_count
//        this.headimgurl = response.data.userinfo.headimgurl
//        this.is_register = response.data.is_register==0 ? false : true
//      }

    },
    mounted () {

//      setTimeout(() => {
//        this.hidden = false
//      }, 1000)

    },
    methods:{
      // 获取url的参数
      getRequest: function() {
        let urlHou = window.location.search; //获取url中"?"符后的字串
        let theRequest = new Object();
        if (urlHou.indexOf("?") != -1) {
          let str = urlHou.substr(1);
          let strs = str.split("&");
          for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
          }
        }
        return theRequest;
      },
      initGetUrl: function(host){
        // hbjr.jinrgame.com
        return 'http://'+host+this.url
      },
    },
    // 注册组件
    components: {
      'loader': RingLoader,
      personalCon,
      jrFooter

    }

  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import '../../common/style/base.styl'

#app
  position relative
  width 10rem
  margin  0 auto
  padding-top rem(42)
  background-color #64acff
  padding-bottom rem(160)



  .erweima-y
    position absolute;
    left 0
    bottom 0rem
    z-index 88
    width rem(430)
    border 2px red solid
    padding 3rem 0 3rem 3rem
    margin -3rem 0 3rem -3rem
    -webkit-user-select: none
    opacity 0

  .loadText
    font-size .3rem
    text-align center
    margin-top 2%
    color #03a9f4

  /* 过渡样式 fade为组件name值*/
  /**
  Enter: v-enter --> v-enter-active
  Leave: v-leave --> v-leave-active
   */
  .fade-enter-active,
  .fade-leave-active
    transition: opacity .5s
  .fade-enter,
  .fade-leave-active
    opacity 0

  .oneScreen
    position relative
    top rem(-300)
    left 50%
    margin-top 100%
    -webkit-transform translate3d(-50%,0%,0)
    transform translate3d(-50%,0%,0)
    /*height 14rem*/

  .v-spinner
    .v-ring1
      margin  0 auto

</style>
